<template>
    <div class="">
        <el-dialog title="编辑社会纠纷登记" :visible.sync="dialog" width="40%" :before-close="dialogClose">
            <el-form ref="formData" :model="formData" label-width="100px">
				<el-form-item label="单位" prop="name">
				    <el-input v-model="formData.unit" placeholder="请输入乡/镇/街道/村/社区"></el-input>
				</el-form-item>
				<el-form-item label="姓名" prop="name">
				    <el-input v-model="formData.baseinfo" placeholder="请输入当事人基本情况："></el-input>
				</el-form-item>
				<el-form-item label="初发时间" prop="name">
				    <el-date-picker
				      v-model="formData.starttime"
				      type="datetime"
					  value-format="timestamp"
				      placeholder="请选择初发时间">
				    </el-date-picker>
				</el-form-item>
				<el-form-item label="发生地点" prop="name">
				    <el-input v-model="formData.address" placeholder="请输入发生地点"></el-input>
				</el-form-item>
				<el-form-item label="简要情况" prop="name">
				    <el-input type="textarea" autosize v-model="formData.desc" placeholder="请输入简要情况"></el-input>
				</el-form-item>
				<el-form-item label="前期情况" prop="name">
				    <el-input type="textarea" autosize v-model="formData.presituation" placeholder="请输入前期情况"></el-input>
				</el-form-item>
				<el-form-item label="风险评估" prop="name">
					<el-select v-model="formData.risk" style="width: 100%;" placeholder="请选择风险评估">
						<el-option label="红" :value="1"></el-option>
						<el-option label="黄" :value="2"></el-option>
						<el-option label="绿" :value="3"></el-option>
					</el-select>
				</el-form-item>
				<el-form-item label="问题症结" prop="phone">
				    <el-input type="textarea" autosize v-model="formData.question" placeholder="请输入问题症结"></el-input>
				</el-form-item>
				<el-form-item label="化解情况" prop="name">
				    <el-input type="textarea" autosize v-model="formData.resolvesituation" placeholder="请输入化解情况"></el-input>
				</el-form-item>
				<el-form-item label="责任人" prop="phone">
				    <el-input v-model="formData.responsible" placeholder="请输入责任人"></el-input>
				</el-form-item>
				<el-form-item label="填报单位" prop="name">
				    <el-input v-model="formData.addunit" placeholder="请输入填报单位"></el-input>
				</el-form-item>
				<el-form-item label="备注" prop="name">
				    <el-input v-model="formData.remark" placeholder="请输入备注"></el-input>
				</el-form-item>
               
            	<el-form-item>
            		<el-button @click="dialogClose">取 消</el-button>
            		<el-button type="primary" @click="formSubmit">确 定</el-button>
            	</el-form-item>
            </el-form>
        </el-dialog>
    </div>
</template>
<script>
    export default {
        data() {
			return {
				dialog: false,
				formData: {
					id: 0,
				}
			}
        },
		created() {
		},
		watch: {
			dialog () {
				if(!this.dialog) {
					this.clearFormData()
					this.$emit('getSocietyledger')
				}
			}
		},
        methods: {
			dialogClose(){
				this.$emit('dialogToggle1')
			},
			clearFormData () {
				for(let i in this.formData){
					if(i == 'id') {
						this.formData[i] = 0
					} else {
						this.formData[i] = ''
					}
				}
			},
			// 保存编辑
			formSubmit() {
				this.formData.starttime = this.formData.starttime/1000
				this.$apiPost('Societyledger/editData', this.formData).then(res => {
					if(res.code == 1) {
						this.$message(res.msg)
						this.dialogClose()
					} else {
						this.$message(res.msg)
					}
				})
			},
        }
    };
</script>
<style scoped>
	.mselect{
		width: 100%;
	}
	.mtdiv{
		margin-top: 10px;
		display: inline-block;
		width: 100%;
	}
	.mtdiv .mtdiv-v{
		float: left;
		width: 50%;
		margin-bottom: 5px;
		display: flex;
		align-items: center;
	}
	.mtdiv .mtdiv-v label{
		float: left;
		margin-right: 10px;
	}
	.mtdiv .el-input{
		float: left;
		width: 80%;
		margin: 5px 0;
	}
</style>
